
var projectName = 'ShopNest';
/**
 * 轮播图配置
 */
var swiper = {
	// 设定轮播容器宽度，支持像素和百分比
	width: '100%',
	height: '400px',
	// hover（悬停显示）
	// always（始终显示）
	// none（始终不显示）
	arrow: 'none',
	// default（左右切换）
	// updown（上下切换）
	// fade（渐隐渐显切换）
	anim: 'default',
	// 自动切换的时间间隔
	// 默认3000
	interval: 2000,
	// 指示器位置
	// inside（容器内部）
	// outside（容器外部）
	// none（不显示）
	indicator: 'outside'
}

/**
 * 个人中心菜单
 */
var centerMenu = [{
	name: 'Personal Center',
	url: '../' + localStorage.getItem('userTable') + '/center.html'
}, 
{
	name: 'My Order',
	url: '../shop-order/list.html'
},

{
	name: 'My address',
	url: '../shop-address/list.html'
},

{
	name: 'My collection',
	url: '../storeup/list.html'
}
]


var indexNav = [

{
	name: ' information',
	url: './pages/shangpinxinxi/list.html'
}, 

{
	name: 'news',
	url: './pages/news/list.html'
},
]

var adminurl =  "http://101.200.235.124:8080/shopNest/admin/dist/index.html";

var cartFlag = false

var chatFlag = false


chatFlag = true
cartFlag = true


var menu = [
    {
        "backMenu": [
            {
                "child": [
                    {
                        "buttons": [
                            "add",
                            "check",
                            "modify",
                            "delete"
                        ],
                        "menu": "user",
                        "menuJump": "list",
                        "tableName": "yonghu"
                    }
                ],
                "menu": "user manage"
            },
            {
                "child": [
                    {
                        "buttons": [
                            "add",
                            "check",
                            "modify",
                            "delete"
                        ],
                        "menu": "classification",
                        "menuJump": "list",
                        "tableName": "shangpinfenlei"
                    }
                ],
                "menu": "classification"
            },
            {
                "child": [
                    {
                        "buttons": [
                            "add",
                            "check",
                            "modify",
                            "delete",
                            "check comment"
                        ],
                        "menu": " information",
                        "menuJump": "list",
                        "tableName": "shangpinxinxi"
                    }
                ],
                "menu": " information manage"
            },
            {
                "child": [
                    {
                        "buttons": [
                            "check",
                            "modify",
                            "delete",
                            " examine",
                            "report"
                        ],
                        "menu": "comments",
                        "menuJump": "list",
                        "tableName": "dingdanpingjia"
                    }
                ],
                "menu": "comments manage"
            },
            {
                "child": [
                    {
                        "buttons": [
                            "add",
                            "check",
                            "modify",
                            "delete"
                        ],
                        "menu": "在线客服",
                        "tableName": "chat"
                    },
                    {
                        "buttons": [
                            "add",
                            "check",
                            "modify",
                            "delete"
                        ],
                        "menu": "轮播图 manage",
                        "tableName": "config"
                    },
                    {
                        "buttons": [
                            "add",
                            "check",
                            "modify",
                            "delete"
                        ],
                        "menu": "news",
                        "tableName": "news"
                    }
                ],
                "menu": "system manage"
            },
            {
                "child": [
                    {
                        "buttons": [
                            "check",
                            "modify",
                            "delete"
                        ],
                        "menu": "Refunded Order",
                        "tableName": "orders/Refunded"
                    },
                    {
                        "buttons": [
                            "check",
                            "modify",
                            "delete"
                        ],
                        "menu": "已完成 Order",
                        "tableName": "orders/已完成"
                    },
                    {
                        "buttons": [
                            "check",
                            "modify",
                            "delete"
                        ],
                        "menu": "已发货 Order",
                        "tableName": "orders/已发货"
                    },
                    {
                        "buttons": [
                            "check",
                            "modify",
                            "delete"
                        ],
                        "menu": "未支付 Order",
                        "tableName": "orders/未支付"
                    },
                    {
                        "buttons": [
                            "check",
                            "modify",
                            "delete"
                        ],
                        "menu": "已取消 Order",
                        "tableName": "orders/已取消"
                    },
                    {
                        "buttons": [
                            "check",
                            "modify",
                            "delete",
                            "发货"
                        ],
                        "menu": "已支付 Order",
                        "tableName": "orders/已支付"
                    }
                ],
                "menu": " Order manage"
            }
        ],
        "frontMenu": [
            {
                "child": [
                    {
                        "buttons": [
                            "check"
                        ],
                        "menu": " informationlist",
                        "menuJump": "list",
                        "tableName": "shangpinxinxi"
                    }
                ],
                "menu": " information模块"
            }
        ],
        "hasBackLogin": "yes",
        "hasBackRegister": "no",
        "hasFrontLogin": "no",
        "hasFrontRegister": "yes",
        "roleName": "seller",
        "tableName": "users"
    },
    {
        "backMenu": [
            {
                "child": [
                    {
                        "buttons": [
                            "add",
                            "check",
                            "modify",
                            "delete"
                        ],
                        "menu": "comments",
                        "menuJump": "list",
                        "tableName": "dingdanpingjia"
                    }
                ],
                "menu": "comments manage"
            },
            {
                "child": [
                    {
                        "buttons": [
                            "check",
                            "delete"
                        ],
                        "menu": "我的收藏 manage",
                        "tableName": "storeup"
                    }
                ],
                "menu": "我的收藏 manage"
            },
            {
                "child": [
                    {
                        "buttons": [
                            "check"
                        ],
                        "menu": "已支付 Order",
                        "tableName": "orders/已支付"
                    },
                    {
                        "buttons": [
                            "check"
                        ],
                        "menu": "Refunded Order",
                        "tableName": "orders/Refunded"
                    },
                    {
                        "buttons": [
                            "check"
                        ],
                        "menu": "已完成 Order",
                        "tableName": "orders/已完成"
                    },
                    {
                        "buttons": [
                            "check",
                            "确认收货"
                        ],
                        "menu": "已发货 Order",
                        "tableName": "orders/已发货"
                    },
                    {
                        "buttons": [
                            "check"
                        ],
                        "menu": "未支付 Order",
                        "tableName": "orders/未支付"
                    },
                    {
                        "buttons": [
                            "check"
                        ],
                        "menu": "已取消 Order",
                        "tableName": "orders/已取消"
                    }
                ],
                "menu": " Order manage"
            }
        ],
        "frontMenu": [
            {
                "child": [
                    {
                        "buttons": [
                            "check"
                        ],
                        "menu": " informationlist",
                        "menuJump": "list",
                        "tableName": "shangpinxinxi"
                    }
                ],
                "menu": " information模块"
            }
        ],
        "hasBackLogin": "yes",
        "hasBackRegister": "no",
        "hasFrontLogin": "yes",
        "hasFrontRegister": "yes",
        "roleName": "buyer",
        "tableName": "yonghu"
    }
]



var isAuth = function (tableName,key) {
    let role = localStorage.getItem("userTable");
    let menus = menu;
    for(let i=0;i<menus.length;i++){
        if(menus[i].tableName==role){
            for(let j=0;j<menus[i].backMenu.length;j++){
                for(let k=0;k<menus[i].backMenu[j].child.length;k++){
                    if(tableName==menus[i].backMenu[j].child[k].tableName){
                        let buttons = menus[i].backMenu[j].child[k].buttons.join(',');
                        return buttons.indexOf(key) !== -1 || false
                    }
                }
            }
        }
    }
    return false;
}

var isFrontAuth = function (tableName,key) {
    let role = localStorage.getItem("userTable");
    let menus = menu;
    for(let i=0;i<menus.length;i++){
        if(menus[i].tableName==role){
            for(let j=0;j<menus[i].frontMenu.length;j++){
                for(let k=0;k<menus[i].frontMenu[j].child.length;k++){
                    if(tableName==menus[i].frontMenu[j].child[k].tableName){
                        let buttons = menus[i].frontMenu[j].child[k].buttons.join(',');
                        return buttons.indexOf(key) !== -1 || false
                    }
                }
            }
        }
    }
    return false;
}
